package cn.tedu.home1ess.admin.navgation.dao.repository.impl;


import cn.tedu.home1ess.admin.navgation.dao.mapper.NavgationMapper;
import cn.tedu.home1ess.admin.navgation.dao.repository.INavgationRepository;
import cn.tedu.home1ess.admin.navgation.pojo.param.NavgationAddParam;
import cn.tedu.home1ess.admin.navgation.pojo.param.NavgationUpdateParam;
import cn.tedu.home1ess.admin.navgation.pojo.po.NavgationPO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Slf4j
@Repository
public class NavgationRepositoryImpl implements INavgationRepository {
    @Autowired
    private NavgationMapper navgationContentMapper;



    @Override
    public List<NavgationPO> selectContent() {
        QueryWrapper queryWrapper=new QueryWrapper();
        return navgationContentMapper.selectList(queryWrapper);
    }

    @Override
    public NavgationPO selectById(Long id) {
        log.error("id:"+id);
        NavgationPO navgationPO = navgationContentMapper.selectById(id);
        log.error("navgationPO:"+navgationPO);
        return navgationPO;
    }

    @Override
    public NavgationPO selectByName(String name) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("name",name);
        log.error("根据name查询结果:"+navgationContentMapper.selectOne(queryWrapper));
        return navgationContentMapper.selectOne(queryWrapper);
    }

    //增加导航
    @Override
    public void save(NavgationPO nPO) {
            navgationContentMapper.insert(nPO);
    }

    //删除导航
    @Override
    public void deleteNavgation(Long id) {
            navgationContentMapper.deleteById(id);
    }

    //修改导航
    @Override
    public void updateNavgation(NavgationPO navgationPO1) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("id",navgationPO1.getId());
        navgationContentMapper.update(navgationPO1,queryWrapper);
    }



}
